<?php
namespace app\admin\controller;

use app\BaseController;
use think\Request;

class Index extends BaseController
{
    public function index(Request $request)
    {
        if ($request->isPost()) {
            $data = $request->param();
            $yzm = captcha_check($request->param('yzm'));

            if ($yzm) {
                return json(['status' => 0, 'msg' => captcha_src()]);
            } else {
                return json(['status' => 0, 'msg' => '验证码错误']);
            }
            //return view('index', ['data' => $data]);
        }
        return view('login');
    }

    public function hello($name = 'ThinkPHP admin')
    {
        return 'hello,' . $name;
    }

    public function detail($user, $id)
    {
        return $user.' id is '.$id;
    }

    public function create($create, $id)
    {
        return $create . ' function id is '. $id;
    }

    public function login()
    {
        $name = [
            'first' => 'php',
            'next' => 'zhi'
        ];
        event('UserLogin', $name);
        event('OutputMyName', [$name]);
    }
}
